﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism;
using Microsoft.Practices.Prism.Regions;

namespace Warehouse.Silverlight.Core.Infrastructure.Views
{
    public class NavigationAwareView : View, INavigationAware
    {
        public NavigationAwareView()
        {
            Setup();
        }

        protected virtual void Setup()
        {
        }

        protected virtual void Cleanup()
        {
        }

        public virtual bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public virtual void OnNavigatedFrom(NavigationContext navigationContext)
        {
            navigationContext.NavigationService.Region.Remove(this);
            Cleanup();
        }

        public virtual void OnNavigatedTo(NavigationContext navigationContext)
        {
        }
    }
}
